﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AgileSaude.Entities;
using System.Web.UI.WebControls;

namespace AgileSaude.Web
{
    public class PageBase : System.Web.UI.Page
    {
        protected override void OnLoad(EventArgs e)
        {
            //if (Session["UserLogado"] == null)
            //{
            //    Response.Redirect("~/Account/Login.aspx", false);
            //}
            //else
            //{
                //UsuarioEntities user = (UsuarioEntities)Session["UserLogado"];

                //if (Request.QueryString["PopUp"] != "PopUp")
                //{
                //    ((Label)Master.FindControl("lblLogin")).Visible = true;
                //    ((Label)Master.FindControl("lblLogin")).Text = user.Nome;
                //}
            //}

            base.OnLoad(e);
        }

        public string getRelativeURL()
        {
            return (ResolveUrl("~").Equals("/") ? "" : ResolveUrl("~").Substring(0, ResolveUrl("~").Length - 1));
        }

        public UsuarioEntities getUsuarioLogado()
        {

            if (Session["UserLogado"] == null)
            {
                Response.Redirect("~/Default.aspx", false);
            }

            UsuarioEntities user = (UsuarioEntities)Session["UserLogado"];
            return user;
        }

        public void LimparSessao()
        {
            //Session["NovosAnexos"] = null;
            //Session.Remove("NovosAnexos");

            //Session["IdPedidoConsulta"] = null;
            //Session.Remove("IdPedidoConsulta");

            //Session["SolicitacaoEntt"] = null;
            //Session.Remove("SolicitacaoEntt");

            //Session["FilenameExcel"] = null;
            //Session.Remove("FilenameExcel");
        }

    }
}